home *** CD-ROM | disk | FTP | other *** search
/ Ultra Pack / UltraComputing Partner Applications.iso / SunLabs / tclTK / src / tcl7.4 / tests / lreplace.test < prev    next >
Encoding:
Text File  |  1995-06-26  |  3.6 KB  |  111 lines

  1. # Commands covered:  lreplace
  2. #
  3. # This file contains a collection of tests for one or more of the Tcl
  4. # built-in commands.  Sourcing this file into Tcl runs the tests and
  5. # generates output for errors.  No output means no errors were found.
  6. #
  7. # Copyright (c) 1991-1993 The Regents of the University of California.
  8. # Copyright (c) 1994 Sun Microsystems, Inc.
  9. #
  10. # See the file "license.terms" for information on usage and redistribution
  11. # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  12. #
  13. # @(#) lreplace.test 1.9 95/06/25 16:38:21
  14.  
  15. if {[string compare test [info procs test]] == 1} then {source defs}
  16.  
  17. test lreplace-1.1 {lreplace command} {
  18.     lreplace {1 2 3 4 5} 0 0 a
  19. } {a 2 3 4 5}
  20. test lreplace-1.2 {lreplace command} {
  21.     lreplace {1 2 3 4 5} 1 1 a
  22. } {1 a 3 4 5}
  23. test lreplace-1.3 {lreplace command} {
  24.     lreplace {1 2 3 4 5} 2 2 a
  25. } {1 2 a 4 5}
  26. test lreplace-1.4 {lreplace command} {
  27.     lreplace {1 2 3 4 5} 3 3 a
  28. } {1 2 3 a 5}
  29. test lreplace-1.5 {lreplace command} {
  30.     lreplace {1 2 3 4 5} 4 4 a
  31. } {1 2 3 4 a}
  32. test lreplace-1.6 {lreplace command} {
  33.     lreplace {1 2 3 4 5} 4 5 a
  34. } {1 2 3 4 a}
  35. test lreplace-1.7 {lreplace command} {
  36.     lreplace {1 2 3 4 5} -1 -1 a
  37. } {a 2 3 4 5}
  38. test lreplace-1.8 {lreplace command} {
  39.     lreplace {1 2 3 4 5} 2 end a b c d
  40. } {1 2 a b c d}
  41. test lreplace-1.9 {lreplace command} {
  42.     lreplace {1 2 3 4 5} 0 3
  43. } {5}
  44. test lreplace-1.10 {lreplace command} {
  45.     lreplace {1 2 3 4 5} 0 4
  46. } {}
  47. test lreplace-1.11 {lreplace command} {
  48.     lreplace {1 2 3 4 5} 0 1
  49. } {3 4 5}
  50. test lreplace-1.12 {lreplace command} {
  51.     lreplace {1 2 3 4 5} 2 3
  52. } {1 2 5}
  53. test lreplace-1.13 {lreplace command} {
  54.     lreplace {1 2 3 4 5} 3 end
  55. } {1 2 3}
  56. test lreplace-1.14 {lreplace command} {
  57.     lreplace {1 2 3 4 5} -1 4 a b c
  58. } {a b c}
  59. test lreplace-1.15 {lreplace command} {
  60.     lreplace {a b "c c" d e f} 3 3
  61. } {a b "c c" e f}
  62. test lreplace-1.16 {lreplace command} {
  63.     lreplace { 1 2 3 4 5} 0 0 a
  64. } {a 2 3 4 5}
  65. test lreplace-1.17 {lreplace command} {
  66.     lreplace {1 2 3 4 "5 6"} 4 4 a
  67. } {1 2 3 4 a}
  68. test lreplace-1.18 {lreplace command} {
  69.     lreplace {1 2 3 4 {5 6}} 4 4 a
  70. } {1 2 3 4 a}
  71. test lreplace-1.19 {lreplace command} {
  72.     lreplace {1 2 3 4} 2 end x y z
  73. } {1 2 x y z}
  74. test lreplace-1.20 {lreplace command} {
  75.     lreplace {1 2 3 4} end end a
  76. } {1 2 3 a}
  77. test lreplace-1.21 {lreplace command} {
  78.     lreplace {1 2 3 4} end 3 a
  79. } {1 2 3 a}
  80. test lreplace-1.22 {lreplace command} {
  81.     lreplace {1 2 3 4} end end
  82. } {1 2 3}
  83.  
  84. test lreplace-2.1 {lreplace errors} {
  85.     list [catch lreplace msg] $msg
  86. } {1 {wrong # args: should be "lreplace list first last ?element element ...?"}}
  87. test lreplace-2.2 {lreplace errors} {
  88.     list [catch {lreplace a b} msg] $msg
  89. } {1 {wrong # args: should be "lreplace list first last ?element element ...?"}}
  90. test lreplace-2.3 {lreplace errors} {
  91.     list [catch {lreplace x a 10} msg] $msg
  92. } {1 {expected integer but got "a"}}
  93. test lreplace-2.4 {lreplace errors} {
  94.     list [catch {lreplace x 10 x} msg] $msg
  95. } {1 {bad index "x": must be integer or "end"}}
  96. test lreplace-2.5 {lreplace errors} {
  97.     list [catch {lreplace x 10 1x} msg] $msg
  98. } {1 {expected integer but got "1x"}}
  99. test lreplace-2.6 {lreplace errors} {
  100.     list [catch {lreplace x 3 2} msg] $msg
  101. } {1 {list doesn't contain element 3}}
  102. test lreplace-2.7 {lreplace errors} {
  103.     list [catch {lreplace x 1 1} msg] $msg
  104. } {1 {list doesn't contain element 1}}
  105. test lreplace-2.8 {lreplace errors} {
  106.     list [catch {lreplace {a b c d} 3 2} msg] $msg
  107. } {1 {first index must not be greater than second}}
  108. test lreplace-2.9 {lreplace errors} {
  109.     list [catch {lreplace {a b c d} end 1} msg] $msg
  110. } {1 {first index must not be greater than second}}
  111.